package cn.joker.controller;


import cn.joker.constant.Result;
import cn.joker.entity.po.Permissions;
import cn.joker.entity.po.Systems;
import cn.joker.entity.vo.PermissionTreeVO;
import cn.joker.services.IPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 权限表（菜单和按钮权限） 前端控制器
 * </p>
 *
 * @author joker
 * @since 2025-04-29
 */
@RestController
@Api(tags = "权限相关接口")
@RequestMapping("/permissions")
public class PermissionsController {
    @Autowired
    private IPermissionService permissionService;

    @PostMapping("/getPermissionTree")
    @ApiOperation("获取项目下面的权限树数据")
    public Result<List<PermissionTreeVO>> getPermissionTree(@RequestBody Systems systems) {
        return permissionService.getPermissionTree(systems);
    }

    @PostMapping("/addPermission")
    @ApiOperation("增加权限数据")
    public Result<String> addPermission(@RequestBody Permissions permissions) {
        return permissionService.addPermission(permissions);
    }
        @PostMapping("/getPermissionByCode")
    @ApiOperation("根据权限编码获取权限信息")
    public Result<Permissions> getPermissionByCode(@RequestBody Permissions permissions) {
        return permissionService.getPermissionByCode(permissions);
    }


}
